package zhizhemodi.tech.short_term_bwork.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import zhizhemodi.tech.short_term_bwork.entity.Plan;

@Repository
public interface PlanMapper extends BaseMapper<Plan> {
    
    @Select("SELECT * FROM plan WHERE " +
            "TIMESTAMPDIFF(SECOND, start_datetime,CURRENT_TIMESTAMP) > #{mins} " +
            "AND TIMESTAMPDIFF(MINUTE, start_datetime, CURRENT_TIMESTAMP) < 600 " +
            "AND publish_state = '未发布' " +
            "ORDER BY start_datetime")
    List<Plan> getStartInNextXmins(Integer mins);

    @Select("SELECT * FROM plan WHERE " + 
            "TIMESTAMPDIFF(MINUTE, end_datetime, CURRENT_TIMESTAMP) < 0 " +
            "AND publish_state = '已发布'")
    List<Plan> getEndPassXmins();
}
